package ua.kpi.apolonov.questions;

import java.util.List;
import ua.kpi.apolonov.answers.Answer;
import ua.kpi.apolonov.parsers.Parsers;

/**
 * @version 4.0 12.03.2013
 * @author Yegor Apolonov
 */

public class YesNoQuestion extends Question {

	private Parsers parser = new Parsers();
	
	public YesNoQuestion(String question, List<Answer> answers) {
    	super(question, answers);
    	setInquiry("\nВведите 'Yes' или 'No'\n>> ");
    }
    
    public float inspectAnswers(String userAnswers) {
        float result = 0;
        String[] userWords = parser.parseTextAnswer(userAnswers);
        
        if(userWords.length == 1) {
        	String userAnswerWord = userWords[0];
        	for(Answer answer : this) {
            	if(answer.getCorrectness() && userAnswerWord.equalsIgnoreCase(answer.getAnswerText())) {
                    result++;
                }
            }
        } else { result = 0;}
        return result;
    }
}
